# import requests, json, datetime
#
#
# def mallsession():  # 请求信息
#     url = "https://passport.mp.mallcoo.cn/Home/PostLogin"
#     payload = 'isCrossDomain=false&ispersistent=true&password=8d66b556cf62879d1215e5ce82aeb846&username=lyggywy'
#
#     headers = {
#         'Accept': '*/*',
#         'X-Requested-With': 'XMLHttpRequest',
#         'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36',
#         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
#         'Sec-Fetch-Site': 'same-origin',
#         'Sec-Fetch-Mode': 'cors',
#         'Sec-Fetch-Dest': 'empty',
#         'Cookie': 'acw_tc=707c9fdc16057551818813416e61051b2e67c7888c377a6844ee8ba801bbce; login_parm=GoSTLkGizMGQIJBwPiBHGoLNsNv7a2Ght1BLQe+mHVSjCxbk+kcZuT70ztFn/iQBLCa59ASqCmY=; mp_session=9A96C0535C4D681CFF77170F11F6E75A9DB73C286D249356C47B69390AE6D0C7B44A439AE85147E07AA6BDA10978BAE58B957D6FDC91F261; mp.mallcoo.cn=0CE597CC2A24AB34CCF51B3B472766E29123D09502CDAE6409C186D6A1CFEEF8AE44816163179AF3E4F0BB1A7E81589387385FCE5540435EF4CC22E9286CFED3D024DD0629FBD059E730958A384BEEE84C9BCECC4210B6992F6FA37776842AF83132324E47AF6BAFF93A38F70DE14B9D60332C15D46B0093FB7E983CC2989257113650397DE0ADF56075698740AF9FE869908DA4CBFF3AE810F4C3E4C083DE44238CB69A'
#     }
#     session = requests.session()
#     req = session.post(url, headers=headers, data=payload)
#     return session
#
#
# # def todayshould():  # 今日停车收费：实收、应收
# #     session = mallsession()
# #     today = datetime.datetime.now().strftime("%Y-%m-%d")
# #     url = "http://10.105.146.46/park/home/financestat/parkingincome.htm?1605602946353&beginTime=" + str(
# #         today) + "%2000%3A00%3A00&endTime=" + str(
# #         today) + "%2023%3A59%3A59&parkID=&headerData%5BcolName%5D=date&headerData%5BexportName%5D=%E6%97%B6%E9%97%B4&headerData%5BcolName%5D=tempPaid&headerData%5BexportName%5D=%E4%B8%B4%E5%81%9C%E5%AE%9E%E6%94%B6(%E5%85%83)&headerData%5BcolName%5D=serviceFeePaid&headerData%5BexportName%5D=%E8%BD%A6%E4%BD%8D%E6%9C%8D%E5%8A%A1%E8%B4%B9(%E5%85%83)&headerData%5BcolName%5D=rentFeePaid&headerData%5BexportName%5D=%E8%BD%A6%E4%BD%8D%E7%A7%9F%E8%B5%81%E8%B4%B9(%E5%85%83)&headerData%5BcolName%5D=userPaymentPaid&headerData%5BexportName%5D=%E5%9B%BA%E5%AE%9A%E7%94%A8%E6%88%B7%E5%85%85%E5%80%BC(%E5%85%83)&headerData%5BcolName%5D=discountValuePaid&headerData%5BexportName%5D=%E5%81%9C%E8%BD%A6%E5%88%B8%E9%94%80%E5%94%AE(%E5%85%83)&headerData%5BcolName%5D=totalPaid&headerData%5BexportName%5D=%E6%80%BB%E6%94%B6%E5%85%A5(%E5%85%83)&loginOperatorName=zhangni&pwd=e780177b13c201764826efb5e2452c70"
# #     tempshould = session.post(url)
# #     tempshould.content.decode()
# #     tempshould = json.loads(tempshould.text)
# #     Paid = tempshould['d'][0]['PaymentAmount']
# #     Receivable = tempshould['d'][0]['OrderTotalAmount']
# #     return Paid, Receivable
#
#
# def firstdayshould():  # 昨日停车收费：实收、应收
#     today = datetime.datetime.now()
#     session = mallsession()
#     yesterday = (today - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
#     url = "https://customapi.mallcoo.cn/wuyuepark/api/bi/reporttemporary"
#     headers = {
#         'Accept': 'application/json, text/plain, */*',
#         'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
#         'mp-session': session.cookies['mp_session'],
#         'Content-Type': 'application/json',
#         'Sec-Fetch-Site': 'same-site',
#         'Sec-Fetch-Mode': 'cors',
#         'Sec-Fetch-Dest': 'empty'
#     }
#     payload = "{\"MallIDs\":[10965],\"StartDate\":\"" + str(
#         yesterday) + "\",\"EndDate\":\"" + str(
#         yesterday) + "\",\"DateType\":\"day\",\"Date\":[\"" + str(
#         yesterday) + "\",\"" + str(
#         yesterday) + "\"]}"
#     tempshould = requests.post(url, data=payload, headers=headers)
#     tempshould.content.decode()
#     tempshould = json.loads(tempshould.text)
#     Paid = int(tempshould['d'][0]['PaymentAmount'])  # 实收金额
#     ROrderTotalAmountes = int(tempshould['d'][0]['OrderTotalAmount'])  # 应收金额
#     OnlineRate = tempshould['d'][0]['OnlineRate']  # 线上缴费占比
#     OffLineRate = tempshould['d'][0]['OffLineRate']  # 线下缴费占比
#     TotalCouponDuration = tempshould['d'][0]['TotalCouponDuration']  # 停车券抵扣时长 分钟
#     TotalCouponDuration = TotalCouponDuration / 60  # 停车券抵扣时长 小时
#     CashAmount = tempshould['d'][0]['CashAmount']  # 现金金额
#     AlipayAmount = tempshould['d'][0]['AlipayAmount']  # 支付宝支付金额
#     WeChatAmount = tempshould['d'][0]['WeChatAmount']  # 微信支付金额
#     AlipayTotal = tempshould['d'][0]['AlipayTotal']  # 支付宝订单
#     WeChatTotal = tempshould['d'][0]['WeChatTotal']  # 微信订单
#     OtherTotal = tempshould['d'][0]['OtherTotal']  # 线下订单
#     PrivilegeTotal = tempshould['d'][0]['PrivilegeTotal']  # 权益订单
#     onlineTotal = int(AlipayTotal + WeChatTotal)  # 线上总单数
#     Total = int(WeChatTotal + AlipayTotal + OtherTotal)  # 线上+线下单数
#     offlineTotalRate = OtherTotal / Total * 100  # 线下订单占比
#     offlineTotalRate = float('%.2f' % offlineTotalRate)  # 线下订单占比精确2位数
#     onlineTotalRate = onlineTotal / Total * 100  # 线上订单占比
#     onlineTotalRate = float('%.2f' % onlineTotalRate)  # 线上订单占比精确2位数
#     # print("实收金额：", Paid, "\n", "应收金额：", ROrderTotalAmountes, "\n", "线上缴费占比：", OnlineRate, "%\n", "线下缴费占比：", OffLineRate,
#     #       "%\n", "停车券抵扣时长：", TotalCouponDuration, "小时", "现金收入：", CashAmount, "\n支付宝收入：", AlipayAmount, "\n微信收入：",
#     #       WeChatAmount)
#     # print("线上订单占比：", onlineTotalRate + "%", "线下订单占比：", offlineTotalRate + "%")
#     return Paid, ROrderTotalAmountes, OnlineRate, OffLineRate, TotalCouponDuration, CashAmount, AlipayAmount, WeChatAmount, onlineTotalRate, offlineTotalRate
#
#
# if __name__ == '__main__':
#     firstdayshould()
